'''
实验名称：舵机实验
接线说明：SG90舵机模块-->ESP32 IO
         橙色(信号线)-->(17)
         红色(电源正)-->(5V)
         褐色(电源负)-->(GND)
         
实验现象：程序下载成功后，SG90舵机循环以45°步进从0°旋转到180°
'''

from machine import Pin
import time
from servo import Servo

# 定义伺服舵机对象
first_servo = Servo(Pin(17))
  
if __name__ == "__main__":
    while True:
        first_servo.write_angle(0)
        time.sleep(0.5)
        first_servo.write_angle(45)
        time.sleep(0.5)
        first_servo.write_angle(90)
        time.sleep(0.5)
        first_servo.write_angle(135)
        time.sleep(0.5)
        first_servo.write_angle(180)
        time.sleep(0.5)

